const request = {
	get(url, data = {}) {
		let str = ''
		let promise = new Promise((resolve, reject) => {
			if (str) {
				for (let key in data) {
					str += `&${key}=${data[key]}`
				}
				str.substring(1)
			}
			uni.request({
				url: 'http://fmyy.syzhijie.com/api/' + url + '?' + str ,
				method: "GET",
				success: res => {
					resolve(res)
				},
				fail: res => {
					reject(res)
					console.log(res)
				},
			})
		})
		return promise
	},
	post(url, data = {}) {
		let promise = new Promise((resolve, reject) => {
			uni.request({
				url: 'http://fmyy.syzhijie.com/api/' + url,
				data: data,
				method: "POST",
				// header: {
				// 	"Access-Control-Allow-Origin": '*'
				// },
				success: (res) => {
					resolve(res)
				},
				fail(err) {
					reject(res)
					console.log(err)
				}
			})
		})
		return promise
	}
}

export default request
